package com.teradata.olingo.processor.core.api;

import org.apache.olingo.commons.api.format.ContentType;
import org.apache.olingo.server.api.*;
import org.apache.olingo.server.api.processor.DefaultProcessor;
import org.apache.olingo.server.api.processor.ErrorProcessor;

public class GenericErrorProcessorWrapper implements ErrorProcessor {
  private final ErrorProcessor defaultProcessor;
  private final GenericErrorProcessor errorProcessor;

  public GenericErrorProcessorWrapper(final GenericErrorProcessor errorProcessor) {
    super();
    this.defaultProcessor = new DefaultProcessor();
    this.errorProcessor = errorProcessor;

  }

  @Override
  public void init(OData odata, ServiceMetadata serviceMetadata) {
    defaultProcessor.init(odata, serviceMetadata);
  }

  @Override
  public void processError(ODataRequest request, ODataResponse response, ODataServerError serverError,
      ContentType responseFormat) {
    errorProcessor.processError(request, serverError);
    defaultProcessor.processError(request, response, serverError, responseFormat);
  }

}
